package com.shxy.entity.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.shxy.util.converter.AbstractEnumConverter;
import com.shxy.util.converter.IEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.lang.Nullable;

/**
 * 职务枚举
 */
@Getter
@AllArgsConstructor
public enum PositionEnum implements IEnum<String> {
    DWSJ("01", "党委书记"),
    YZ("02","院长"),
    DWFSJ("03","党委副书记"),
    FYZ("04","副院长"),
    JWSJ("05","纪委书记"),
    GHZX("05","工会主席"),
    ZR("05","主任"),
    FZR("05","副主任"),
    BZ("05","部长"),
    FBZ("05","副部长"),
    CZ("05","处长"),
    FCZ("05","副处长"),
    EJXYYZ("05","二级学院院长"),
    EJXYFYZ("05","二级学院副院长"),
    SXZXZR("05","实习中心主任"),
    SXZXFZR("05","实习中心副主任"),

    ;
    private String code;
    private String name;

    /**
     * 类型转换器
     */
    public static class Converter extends AbstractEnumConverter<PositionEnum, String> {
        public Converter() {
            super(PositionEnum.class);
        }
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    @Nullable
    public static PositionEnum resolve(String name) {
        for(PositionEnum positionEnum: PositionEnum.values()) {
            if(name.equals(positionEnum.getName())){
                return positionEnum;
            }
        }
        return null;
    }
}
